package io.renren.modules.jxgkquestion.dao;


import java.util.List;
import io.renren.modules.jxgkquestion.entity.QuestionBankEntity;
import io.renren.modules.jxgkquestion.entity.ScoreDataEntity;
import io.renren.modules.sys.dao.BaseDao;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Repository
@Mapper
public interface QuestionBankDao extends BaseDao<QuestionBankEntity>{
    @Select("select student_department_name from class_course WHERE course_time>\"2018-03-01\" and student_department_name!=\"无\"GROUP BY  student_department_name")
    List<String> findAllDepartmentType();
    @Select("SELECT * FROM question_bank WHERE question_department=#{departmentType} ORDER BY RAND() LIMIT 5")
    List<QuestionBankEntity> findQuestionByDepartmentType(String departmentType);
    @Select("select score_amount,score_question_amount,score_question_rate from score_question where score_student_id=#{scoreStudentId} AND " +
            "score_subject_name=#{scoreSubjectName}")
    ScoreDataEntity findCurrentScoreInfoByIdAndSubject(@Param("scoreStudentId") String scoreStudentId,
                                          @Param("scoreSubjectName") String scoreSubjectName);
    @Insert("Insert into score_question(" +
            "            score_student_id," +
            "            score_subject_id," +
            "            score_amount," +
            "            score_question_amount," +
            "            score_question_rate," +
            "            score_subject_name) " +
            "values(" +
            "#{scoreStudentId}," +
            "#{scoreSubjectId}," +
            "#{scoreAmount}," +
            "#{scoreQuestionAmount}," +
            "#{scoreQuestionRate}," +
            "#{scoreSubjectName}" +
            ")")
    void insertScoreAmount(ScoreDataEntity sde);
    @Update("Update score_question " +
            "Set " +
                "score_amount=#{scoreAmount}," +
                "score_question_amount=#{scoreQuestionAmount}," +
                "score_question_rate=#{scoreQuestionRate} " +
            "Where " +
                "score_student_id=#{scoreStudentId} And " +
                "score_subject_name=#{scoreSubjectName}")
    void updateScoreAmount(ScoreDataEntity sde);
}
